<template>
  <div id="home">
    <!-- 导航栏 -->
    <nav>
      <ul>
        <li><router-link to="/">首页</router-link></li>
        <li><router-link to="/wordcloud">词云</router-link></li>
        <li><router-link to="/about">关于</router-link></li>
      </ul>
    </nav>

    <!-- 页面内容 -->
    <main>
      <router-view />
      <button @click="goFullScreen">进入全屏</button>
    </main>
  </div>
</template>

<script setup name="Home">

const goFullScreen = function() {
  // 检查浏览器支持全屏 API
  const docElm = document.documentElement;
  if (docElm.requestFullscreen) {
    docElm.requestFullscreen();
  } else if (docElm.mozRequestFullScreen) { // Firefox
    docElm.mozRequestFullScreen();
  } else if (docElm.webkitRequestFullscreen) { // Chrome, Safari 和 Opera
    docElm.webkitRequestFullscreen();
  } else if (docElm.msRequestFullscreen) { // IE/Edge
    docElm.msRequestFullscreen();
  }
}
</script>

<style scoped>
/* 使页面充满整个屏幕 */
html, body {
  height: 100%;
  margin: 0;
}

/* 页面容器 */
#home {
  padding: 0%;
  width: 100%;
  font-family: 'Arial', sans-serif;
  color: #333;
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* 使容器高度至少为视口高度 */
  justify-content: space-between; /* 使内容区占满可用空间 */
}

/* 导航栏样式 */
nav {
  background-color: #0e3d69;
  padding: 1rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

nav ul {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 0;
  padding: 0;
  list-style-type: none;
}

nav ul li {
  position: relative;
}

nav ul li a {
  color: #fff;
  font-size: 1.2rem;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

nav ul li a:hover {
  background-color: #42b883;
  transform: scale(1.1);
}

/* 页面内容 */
main {
  flex-grow: 1;
  padding: 2rem;
  background-color: #f8f8f8;
}

main h1 {
  color: #0e3d69;
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

/* 响应式设计：适配小屏幕 */
@media (max-width: 768px) {
  nav ul {
    flex-direction: column;
    align-items: center;
  }

  nav ul li {
    margin-bottom: 1rem;
  }

  main {
    padding: 1rem;
  }
}
</style>
